package com.manager.course;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * CourseValidator.
 */
public class CourseValidator extends Validator {
	
	protected void validate(Controller controller) {
		validateRequiredString("course.course_name", "courseNameMsg", "请输入课程名字!");
	}
	
	protected void handleError(Controller controller) {
		controller.keepModel(Course.class);
		
		String actionKey = getActionKey();
		
		if (actionKey.equals("/course/save"))
			controller.render("add.html");
		else if (actionKey.equals("/course/update"))
			controller.render("edit.html");
	}
}
